package com.work.washer.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.work.washer.mapper.UseRecordMapper;
import com.work.washer.model.UseRecord;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author
 * @description 针对表【type】的数据库操作Service实现
 * @createDate 2024-02-20 10:07:14
 */
@Service
public class UseRecordService extends ServiceImpl<UseRecordMapper, UseRecord>
        implements IService<UseRecord> {

    public List<UseRecord> getByMachineId(Integer machineId) {
        return lambdaQuery().eq(UseRecord::getMachineId, machineId)
                .ne(UseRecord::getStatus, 3)
                .ge(UseRecord::getEndTime, new Date()).list();
    }

    public UseRecord getByUserIdAndMachineId(Integer userId, Integer machineId) {
        return lambdaQuery().eq(UseRecord::getMachineId, machineId)
                .eq(UseRecord::getUserId, userId)
                .eq(UseRecord::getStatus, 1)
                .one();
    }

}




